package com.fu.jdbc05.handler;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;

/**
 * @author 付大大
 * @description
 * @create 2021-02-01 10:14
 */
public class ScalarHandler<T> implements ResultSetHandler<T> {

    @Override
    public Long handler(ResultSet resultSet) {
        Long value = null;
        try {
            if (resultSet.next()) {
                ResultSetMetaData metaData = resultSet.getMetaData();
                String columnName = metaData.getColumnName(1);
                value = resultSet.getLong(columnName);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return value;
    }
}
